import 'dart:io';

import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:oktoast/oktoast.dart';

import './res/resources.dart';
import 'routers/application.dart';
import 'routers/routers.dart';
import 'ui/home/splash_page.dart';

void main() {
  runApp(MyApp());
  if (Platform.isAndroid) {
    //针对Android平台 设置状态栏一体化
    SystemChrome.setSystemUIOverlayStyle(
        SystemUiOverlayStyle(statusBarColor: Colors.transparent));
  }
}

class MyApp extends StatelessWidget {
  MyApp() {
    final router = Router();
    Routes.configureRoutes(router);
    Application.router = router;
  }

  @override
  Widget build(BuildContext context) {
    return OKToast(
      child: MaterialApp(
        title: 'Flutter Demo',
        debugShowCheckedModeBanner: false,  //是否显示debug角标
        theme: ThemeData(
            primaryColor: Colorful.app_main,
            scaffoldBackgroundColor: Colors.white), //主题
        home: SplashPage(),   //启动页
        onGenerateRoute: Application.router.generator,
      ),
      backgroundColor: Colors.black54, //吐司背景颜色
      textPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
      radius: 20,
      position: ToastPosition.bottom,
      //吐司弹出的位置
      dismissOtherOnShow: true, //吐司弹出规则
    );
  }
}
